package cycling.taxi.com.ui.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import cycling.taxi.com.R;
import cycling.taxi.com.entity.Tips;
import cycling.taxi.com.person.ExitApplication;
import cycling.taxi.com.request.RequestCallback;
import cycling.taxi.com.ui.fragment.TipsFrgt;
import cycling.taxi.com.utils.LogUtil;
import cycling.taxi.com.utils.ToastUtil;
import cycling.taxi.com.utils.Urls;

public class TipsItem extends AppCompatActivity implements View.OnClickListener{
    private TextView textView,title;
    private ImageView back;
    private WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tips_item);
        ExitApplication.getInstance().addActivity(this);
        initView();
        initData();
        initLinstener();
    }
    public void initView(){
        textView=(TextView)findViewById(R.id.tipscontent);
        title=(TextView)findViewById(R.id.title_text);
        back=(ImageView) findViewById(R.id.back);
        webView=(WebView)findViewById(R.id.webView);
    }
    public void initData(){
        Tips tip=(Tips)getIntent().getSerializableExtra("Tip");
        String tips=new Gson().toJson(tip);
        String titles=tip.getTitle().replace("%","%25");
        webView.loadUrl(Urls.getTipsItems()+"?tips_id="+tip.getId());
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return super.shouldOverrideUrlLoading(view, url);
            }
        });
        title.setText("贴士专题");
    }
    public void initLinstener(){
        back.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        if (v.getId()==R.id.back){
            finish();
        }
    }
}
